package com.chen.rabbitmq.six;

import com.chen.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @author Y·C
 * @version 1.0.0
 * @ClassName EmitLogDirect.java
 * @Description 直接交换机 需要在basicPublish(中第二个参数)
 * @createTime 2023年05月10日 16:17:00
 */
public class EmitLogDirect {

    //交换机的名称
    public static final String EXCHANGE_NAME = "direct_logs";

    public static void main(String[] args) throws Exception {

        Channel channel = RabbitMqUtils.getChannel();

        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()){
            String message = scanner.next();
            channel.basicPublish(EXCHANGE_NAME,"error",null,message.getBytes("UTF-8"));
            System.out.println("生产者发出消息：" + message);
        }
    }


}
